<?php

namespace App\Observers\Plane;

use App\Models\Plane\Cities\PlaneCity;
use Illuminate\Support\Facades\Cache;

class PlaneCitiesObserver
{
    public function created(PlaneCity $PlaneCities)
    {
        $cache_key_code = "PlaneCities:Code:{$PlaneCities->getCode()}";
        Cache::put($cache_key_code, $PlaneCities, 30 * config('trip.ttl.day'));
    }

    /**
     * Handle the User "updated" event.
     *
     * @param PlaneCity $PlaneCities
     * @return void
     */
    public function updated(PlaneCity $PlaneCities)
    {
        $cache_key_code = "PlaneCities:Code:{$PlaneCities->getCode()}";
        Cache::put($cache_key_code, $PlaneCities, 30 * config('trip.ttl.day'));
    }

    public function deleted(PlaneCity $PlaneCities)
    {
        $cache_key_code = "PlaneCities:Code:{$PlaneCities->getCode()}";
        Cache::forget($cache_key_code);
    }
}
